package v0929;

import java.io.*;
import java.util.Scanner;

public class Testtoday {
    public static void main(String[] args) throws Exception {
        File file=new File("wf/wffortest/test.txt");
        System.out.println(file.exists()?"在的":"不在");
        File file1 = new File("wf/wffortest");
        File[] files = file1.listFiles();
        for (File file2 : files) {
            System.out.println(file2.getName());
        }
        FileInputStream fis = new FileInputStream("wf/wffortest/xhd.png");
        FileOutputStream fos = new FileOutputStream("wf/wffortest/xhd_copy.png");
        long start=System.currentTimeMillis();
        byte[] b=new byte[1024];
        while (fis.read(b)!=-1){
            fos.write(b);
        }
        long ends=System.currentTimeMillis();
        System.out.println("用时："+((ends-start)/1000));
        File f1=new File("wf/wffortest/test");
        if (!f1.exists()) System.out.println(f1.mkdir()?"创建成功":"创建失败");
        File file2 = new File("wf/wffortest/test/test.txt");
        System.out.println(file2.createNewFile()?"创建成功":"创建失败");
        file2.delete();
        FileOutputStream stream = new FileOutputStream("wf/wffortest/test/test.txt");
        stream.write(97);
        stream.write(98);
        stream.write(99);
        stream.write(100);
        File f23=new File("wf/wffortest/test/test1/test2/test3");
        f23.mkdirs();
        f23.listFiles((o1)->o1.getName().toUpperCase().contains("C"));//lambda写法
        FileFilter f12=new FileFilter() {
            @Override
            public boolean accept(File pathname) {
                return pathname.getName().contains("s");
            }
        };
        f23.listFiles(f12);
        System.out.println();
        System.out.println();
        System.out.println();
        System.out.println();
    }
}
